package com.openflag.bwicservice.util;

import com.openflag.bwicservice.domain.Result;
import com.openflag.bwicservice.domain.ResultStatus;
public class ResultUtil {
    // 输入内容，返回带有成功状态信息的带有内容的Object变量。
    public static Result success(Object object){
        Result result = result(ResultStatus.SUCCESS);
        result.setData(object);
        return result;
    }

    // 返回对应状态信息的空内容Result变量。
    public static Result result(ResultStatus status) {
        Result result = new Result();
        result.setCode(status.getValue());
        result.setMsg(status.getReasonPhrase());

        return result;
    }

    // 通用错误信息
    public static Result fail(ResultStatus status) {
        return result(status);
    }

    //定制错误信息
    public static Result fail(Integer code, String msg) {
        Result result = new Result();
        result.setCode(code);
        result.setMsg(msg);

        return result;
    }
}
